Skip to content

[feat] Pulsar authentication for Client authentication using private_key_jwt method#24631

Open
dlg99 wants to merge 1 commit intoapache:masterfrom
dlg99:oath-jwt
Open

[feat] Pulsar authentication for Client authentication using private_key_jwt method#24631
dlg99 wants to merge 1 commit intoapache:masterfrom
dlg99:oath-jwt

Conversation

@dlg99
Copy link
Contributor

@dlg99 dlg99 commented Aug 14, 2025

Fixes #22371

Motivation

support private_key_jwt client authentication

Modifications

Implemented authentication, added tests

Verifying this change

  • Make sure that the change passes the CI checks.

This change added unit tests

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: dlg99#24

@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Aug 14, 2025
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the review comments.

<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>${jsonwebtoken.version}</version>
<scope>runtime</scope>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope shouldn't be added to dependencyManagement dependencies since dependencyManagement's purpose is to pin the version of a dependency, regardless of the scope of the actual dependency.

<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId> <!-- or jjwt-gson if Gson is preferred -->
<version>${jsonwebtoken.version}</version>
<scope>runtime</scope>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove scope

Comment on lines +42 to +60
/**
* Class for reading RSA private key from PEM file. It uses
* the JMeter FileServer to find the file. So the file should
* be located in the same directory as the test plan if the
* path is relative.
* <p>
* <p/>There is a cache so each file is only read once. If file
* is changed, it will not take effect until the program
* restarts.
* <p>
* <p/>It can read PEM files with PKCS#8 or PKCS#1 encodings.
* It doesn't support encrypted PEM files.
* <p>
* "borrowed" from https://github.com/groovenauts/jmeter_oauth_plugin/blob/master/jmeter/
* src/main/java/org/apache/jmeter/protocol/oauth/sampler/PrivateKeyReader.java
* with some modifications:
* - not tied to key specified as a file path
* - minus extra dependencies from jmeter
* - minus key caching
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a copyright issue in "borrowing", although it's ASL 2.0 licensed. I think it would be better to use a similar approach as is used in Zookeeper, https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/util/PemReader.java . That is from another ASF project, https://github.com/airlift/airlift/blob/master/security/src/main/java/io/airlift/security/pem/PemReader.java .
The benefit would also be that it would support also EC keys which are commonly preferred over RSA keys.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach would be to use Pulsar's existing PEM key support classes and improve them if there's a gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-required Your PR changes impact docs and you will update later. ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Pulsar authentication for Client authentication using private_key_jwt method

2 participants